from django.db import models

from home.models import CategoryModel
from utils.BaseModels import BaseModel


# Create your models here.
class TeacherModel(BaseModel):
    name = models.CharField(max_length=20,verbose_name="教师名称")
    job = models.CharField(max_length=20,verbose_name="教师职务")
    intro = models.TextField(verbose_name="教师简介")
    headimg = models.CharField(max_length=200,verbose_name="教师头像")
    def __str__(self):
        return self.name
    class Meta:
        db_table = 'fgteacher'
class CourseModel01(BaseModel):
    name = models.CharField(max_length=20,verbose_name="课程名称")
    category = models.ForeignKey(CategoryModel,on_delete=models.CASCADE,verbose_name="课程分类")
    teacher = models.ForeignKey(TeacherModel,on_delete=models.CASCADE,verbose_name="授课教师",null=True,blank=True)
    intro = models.TextField(verbose_name="课程简介")
    price = models.DecimalField(max_digits=10,decimal_places=2,verbose_name="课程价格")
    timeline = models.IntegerField(default=0)
    counts = models.IntegerField(default=0)
    is_good= models.BooleanField(default=False,verbose_name="是否精品")
    is_hot = models.BooleanField(default=False,verbose_name="是否热销")
    is_home = models.BooleanField(default=False,verbose_name="是否推荐到首页广告")
    level = models.IntegerField(choices=((0,"初级"),(1,'中级'),(2,'高级')),default=0)
    cover = models.CharField(max_length=200,verbose_name="课程封面")
    video = models.CharField(max_length=200,verbose_name="课程简介视频")
    score = models.FloatField(default=10.0,verbose_name="评分")
    def __str__(self):
        return self.name
    class Meta:
        db_table = 'fgcourse'
